home *** CD-ROM | disk | FTP | other *** search
- Path: ip-salem3-09.teleport.com!user
- From: dynamix@teleport.com (Steve Budrys)
- Newsgroups: comp.lang.c++
- Subject: Re: OOPS! - Re: How to delete array of pointers?
- Date: Wed, 14 Feb 1996 16:56:20 -0800
- Organization: Dynamix Trading
- Message-ID: <dynamix-1402961656200001@ip-salem3-09.teleport.com>
- References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> <4fi8rd$738@reader2.ix.netcom.com> <4fkv8j$kb@cloner3.netcom.com>
- NNTP-Posting-Host: ip-salem3-09.teleport.com
-
- In article <4fkv8j$kb@cloner3.netcom.com>, swampwiz@ix.netcom.com(Jean P.
- Laborde ) wrote:
-
- > OOPS !
- >
- > In <4fi8rd$738@reader2.ix.netcom.com> swampwiz@ix.netcom.com(Jean P.
- > Laborde ) writes:
- > >In <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> ywleung@cs.cuhk.hk (Marty McFly)
- > >writes:
- > >>If I write the following code in a function:
- > >> int** ptr;
- > >> ptr = new int*[1000];
- > >>Is this code means allocating 1000 integer pointers which is pointed
- > >by ptr?
- > >>And then somehow I assign integer variable to ptr[0], ptr[1], ... and
- > >so on.
- > >>So at the end of the function, how can I reclaim just those pointers?
- >
- > >The key
- > >>point is that those integer variable assigned to the pointers should
- > >not be
- > >>deleted.
- >
- > I mistakenly said:
- > >
- > >for(int i=0;i<1000;i++)
- > > delete ptr[i];
- > >delete ptr;
- >
- > I should have said at the last line
- >
- > delete ptr [];
-
- Why correct only that part and leave the serious error alone? He
- never said that he 'newed' any memory to those pointers, and he
- _did_ say that he did not want to affect to what those pointers pointed.
-
- --
- Steve Budrys
- Dynamix Trading
-